#pragma once

#include "IGameState.h"
#include "CGame.h"
#include "SGD_Math.h"
#include "Globals.h"
#include "Messaging/MessageSystem.h"
#include "Messaging/EventSystem.h"
#include "Messaging/IListener.h"

class CObjectFactory;
class CObjectManager;
class CHud;
class CPlayer;
class CEnemy;
class CCamera;



class CGamePlayState : public IGameState, public IListener
{
private:
	//TODO:
	MessageSystem*			m_pMS;
	EventSystem*			m_pES;
	CObjectFactory*			m_pOF;
	CObjectManager*			m_pOM;
	CHud*					m_HudObject;
	CCamera*				m_pCamera;
	//int m_nBGM; TODO: change to world map

	int			m_nScreenWidth;
	int			m_nScreenHeight;
	int			m_nFrameCounter;	// counts out the number of frames for FPS
	DWORD		m_dwCurrentTime;	// resets every second of time
	DWORD		m_dwLastUpdateTime;
	DWORD		m_dwElapsedTime;

	int			m_nBGM[1];		//TODO: use a more appropriate number than one
	int			m_nSoundID[1];	//TODO: use a more appropriate number than one
	//objects used in the game

	// Our glorious players
	CPlayer*	m_pPlayerOne;
	CPlayer*	m_pPlayerTwo;
	CEnemy*		m_pTestEnemy;

	//Pause menu...stuff
	bool bIsPaused;
	int m_nMenuSelection;
	int m_nCursorID;
		

	bool bDebugModeOn;
	bool m_bGameIsOver;

	
	//cheats
	bool		m_bCheat_OneHitKill;	// If on, the player kills all enemies with one hit
	bool		m_bCheat_Invincibility;	// If on, the player takes no damage
	

	CGamePlayState( void );
	CGamePlayState( const CGamePlayState& );
	CGamePlayState& operator=( const CGamePlayState& );
	~CGamePlayState(void);

public:
	static CGamePlayState* GetInstance( void );

	/////////////////////////
	// MUTATORS
	////////////////////////
	void SetPaused(bool bPaused)			{ bIsPaused = bPaused; }
	void SetSoundID(int nEffect, int nSoundID)	{m_nSoundID[nEffect] = nSoundID;}
	void SetOneHitKill (bool bOneHitKill)	{ m_bCheat_OneHitKill = bOneHitKill; }
	void SetInvincibility(bool bInvincible)	{ m_bCheat_Invincibility = bInvincible; }
	void SetGameIsOver(bool gameOver)		{ m_bGameIsOver = gameOver; }

	///////////////////////
	// ACCESSORS
	///////////////////////
	bool GetPaused() const					{ return bIsPaused; }
	bool GetDebugModeOn() const				{ return bDebugModeOn;}
	int  GetSoundID(int effect) const		{ return m_nSoundID[effect]; }
	bool GetOneHitKill() const				{ return m_bCheat_OneHitKill; }
	bool GetInvincibility() const			{ return m_bCheat_Invincibility; }
	bool GetGameIsOver() const				{ return m_bGameIsOver; }
	
	// Plays a sound effect with the given sound ID at the preset volume setting and with panning
	void PlayPannedSound (int nFModSoundID, float nSoundLocation);

	// Register a class object with the object factory and add it to the object manager
	template <typename T>
	void RegisterObject(T classType, string className, T* objectPointer);

	void Enter(void);
	bool Input(void);
	void Update(float fElapsedTime);
	void Render(void);
	void Exit(void);
	static void MessageProc(CBaseMessage* pMsg);
	void HandleEvent(CEvent* pEvent);
	void HandlePlayerOneInput();
	// draws the HUD bar border, the Xbox 360 buttons, the player icons, and the radar
	//void DrawHUDBar();

};


	